package com.atguigu.gmall.weball.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.feign.order.OrderFeignClient;
import com.atguigu.gmall.order.vo.OrderConfirmVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * @Description
 * @Return
 * @Author https://weiranyi.github.io
 * @Date Created in 2022-12-20 17:36
 **/
@Controller
public class OrderController {
    @Autowired
    OrderFeignClient orderFeignClient;

    // 订单确认页& http://order.gmall.com/trade.html
    @GetMapping("/trade.html")
    public String toTradePage(Model model) {
        Result<OrderConfirmVo> orderConfirmData = orderFeignClient.getOrderConfirmData();
        OrderConfirmVo orderConfirmVo = orderConfirmData.getData();
        // 详情页-商品清单
        model.addAttribute("detailArrayList", orderConfirmVo.getDetailArrayList());
        // 详情页-商品总数
        model.addAttribute("totalNum", orderConfirmVo.getTotalNum());
        // 详情页-商品价格
        model.addAttribute("totalAmount", orderConfirmVo.getTotalAmount());
        // 详情页-用户地址列表
        model.addAttribute("userAddressList", orderConfirmVo.getUserAddressList());
        // 详情页-交易流水号
        model.addAttribute("tradeNo", orderConfirmVo.getTradeNo());

        return "order/trade";
    }

    //http://order.gmall.com/myOrder.html
    @GetMapping("/myOrder.html")
    public String toMyOrderPage(){
        return "order/myOrder";
    }
    
}
